package com.zheng.damo01.作业;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.function.Consumer;

public class MainApp {
    public static void main(String[] args) {
        Student1 s1 = new Student1("it001", "黄渤","男",20, 1.72);
        Student1 s2 = new Student1("it002", "孙红雷", "男",22,1.78);
        Student1 s3 = new Student1("it003", "章子怡", "nv",18,1.64);
        ArrayList<Student1> list=new ArrayList<>();
        Collections.addAll(list,s1,s2,s3);
        printAll(list);
        System.out.println("-------------------------");
        findMaxHeight(list);

    }
    public static void printAll(ArrayList<Student1>stuList){
        Iterator<Student1> it=stuList.iterator();
        while (it.hasNext()){
            Student1 next = it.next();
            System.out.println(next);
        }
    }
    public static void findMaxHeight(ArrayList<Student1>stuList){
        int max=0;
        for (int i = 1; i < stuList.size(); i++) {
            if (stuList.get(i).getHigh()>stuList.get(max).getHigh()){
                max=i;
            }
        }
        System.out.println(stuList.get(max));
    }


}
class Student1{
    private String ID;
    private String name;
    private String sex;
    private Integer age;
    private Double high;

    public Student1(String ID, String name, String sex, Integer age, Double high) {
        this.ID = ID;
        this.name = name;
        this.sex = sex;
        this.age = age;
        this.high = high;
    }

    @Override
    public String toString() {
        return "Student1{" +
                "ID='" + ID + '\'' +
                ", name='" + name + '\'' +
                ", sex='" + sex + '\'' +
                ", age=" + age +
                ", high=" + high +
                '}';
    }

    public String getID() {
        return ID;
    }

    public void setID(String ID) {
        this.ID = ID;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Double getHigh() {
        return high;
    }

    public void setHigh(Double high) {
        this.high = high;
    }
}